﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Media.Imaging;
using System.Text.RegularExpressions;
using System.Reflection;
using Microsoft.Phone.Tasks;

namespace TravelWallet
{
    public partial class About : PhoneApplicationPage
    {
        public About()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(About_Loaded);
        }

        void About_Loaded(object sender, RoutedEventArgs e)
        {
            BitmapImage image = new BitmapImage(new Uri("TW_AppTileImg_Trans_173x173.png", UriKind.Relative));
            img_logo.Source = image;
            tb_Version.Text = CurrentVersion;

        }

        public static string CurrentVersion
        {

            get
            {
                string retval = "Version: ";

                Regex regex = new Regex(@", Version=(?<Version>\d+.\d+.\d+.\d+)", RegexOptions.Singleline);

                Match match = regex.Match(Assembly.GetExecutingAssembly().FullName);

                if (match.Success)
                {

                    return retval+= match.Groups["Version"].Value;

                }

                return retval;

            }

        }

        private void btn_Rate_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();

            marketplaceReviewTask.Show();
        }

        private void buttonFacebook_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            WebBrowserTask task = new WebBrowserTask();
            task.URL = "http://www.facebook.com/TravelWallet";
            task.Show();
        }

        private void buttonTwitter_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            WebBrowserTask task = new WebBrowserTask();
            task.URL = "http://www.twitter.com/TravelWallet";
            task.Show();
        }

    }
}